use tauri_plugin_fs::FsExt;
use utils::mysql_utils::init_mysql_pool;

// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
pub mod dao;
pub mod service;
pub mod utils;

#[tokio::main]
async fn _init() {
    //init_mysql_pool("mysql://账号:密码@数据库地址/数据库");
    init_mysql_pool("mydatabase.db", "".to_string()).await;
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        
        .setup(|app| {
            #[cfg(mobile)]
            app.handle().plugin(tauri_plugin_haptics::init());
            Ok(())
        })
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_sql::Builder::new().build())
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![
            service::ageing_service::save_ageing,
            service::ageing_service::update_ageing,
            service::ageing_service::get_info_by_date,
            service::ageing_service::get_list_by_date,
            service::ageing_service::get_list_by_dates,
            service::mysql_service::init_sql_pool,
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
